<template>
<div class="w-full min-h-screen" style="background-color: var(--content-bg-color)">

</div>

    <div class="container mx-auto max-w-screen-xl px-4 py-8">
      
    </div>
  </template>
  
  <script setup>
  import UserInfoCard from '@/layouts/client/modules/UserInfoCard.vue';
  import { getArticleDetail } from '@/service/api/frontend/article';
  import { getCategories } from '@/service/api/frontend/category';
  import { getTags } from '@/service/api/frontend/tag';
  import { useRoute, useRouter } from 'vue-router';
  import { reactive, ref } from 'vue';
      
  const router = useRouter()
  const route = useRoute()
  const article = reactive({
      title: '深入理解Vue 3响应式系统原理及其应用',
      content: '<p>Vue 3的响应式系统是其核心特性之一，它使开发者能够以声明式的方式构建用户界面...</p>',
      updateTime: '2023年10月15日',
      readNum: 2548,
      categoryId: 1,
      categoryName: '前端开发',
      preArticleId: 101,
      preArticleTitle: 'Vue 3组件设计模式与实践',
      nextArticleId: 103,
      nextArticleTitle: 'Vue 3状态管理：Pinia深度解析',
      tags: [
        { id: 1, name: 'Vue3' },
        { id: 2, name: '响应式编程' },
        { id: 3, name: 'CompositionAPI' }
      ],
  })
  
  function queryArticleDetail(articleId) {
      console.log('调用获取详情接口...' + route.query.articleId)
      // 模拟API调用
      setTimeout(() => {
          article.title = '深入理解Vue 3响应式系统原理及其应用';
          article.content = `
            <p>Vue 3的响应式系统是其核心特性之一，它使开发者能够以声明式的方式构建用户界面。与Vue 2相比，Vue 3的响应式系统进行了全面重构，使用了ES6的Proxy替代了Object.defineProperty，带来了显著的性能提升和更强大的功能。</p>
            <h2>响应式系统的基本原理</h2>
            <p>Vue 3的响应式系统基于JavaScript的Proxy实现。Proxy对象用于创建一个对象的代理，从而实现基本操作的拦截和自定义（如属性查找、赋值、枚举、函数调用等）。</p>
            <pre><code class="language-javascript">function reactive(target) {
    return new Proxy(target, {
      get(obj, key) {
        track(obj, key); // 追踪依赖
        return Reflect.get(obj, key);
      },
      set(obj, key, value) {
        Reflect.set(obj, key, value);
        trigger(obj, key); // 触发更新
        return true;
      }
    });
  }
  
  // 使用示例
  const state = reactive({
    count: 0
  });
  
  state.count++; // 触发更新</code></pre>
            <h3>响应式系统的优势</h3>
            <ul>
              <li><strong>更完善的数组支持</strong>：Proxy可以检测到数组索引变化和length变化</li>
              <li><strong>更好的性能</strong>：只在访问属性时递归响应式转换</li>
              <li><strong>支持Map、Set等集合类型</strong>：直接处理ES6集合类型</li>
              <li><strong>更细粒度的依赖追踪</strong>：精确追踪每个属性的依赖关系</li>
            </ul>
          `;
          article.updateTime = '2023年10月15日';
      }, 300);
  }
  queryArticleDetail(route.query.articleId);
  
  const goArticleDetail = (articleId) => {
      console.log('跳转详情页' + articleId)
      router.push({ path: '/client/home/article-detail', query: { articleId: articleId } })
      queryArticleDetail(articleId)
  }
  
  // 获取分类
  const categories = ref([
    { id: 1, name: '前端开发' },
    { id: 2, name: '后端技术' },
    { id: 3, name: '移动开发' },
    { id: 4, name: '数据库' }
  ])
  
  // 获取标签
  const tags = ref([
    { id: 1, name: 'Vue.js' },
    { id: 2, name: 'React' },
    { id: 3, name: 'TypeScript' },
    { id: 4, name: 'Node.js' },
    { id: 5, name: 'Webpack' },
    { id: 6, name: 'Docker' },
    { id: 7, name: '微服务' },
    { id: 8, name: '算法' }
  ])
  
  const goCatagoryArticleListPage = (id, name) => {
      router.push({ path: '/client/category/category-article', query: { id: id, name: name } })
  }
  
  const goTagArticleListPage = (id, name) => {
      router.push({ path: '/client/tags/tag-article', query: { id: id, name: name } })
  }
  </script>
  
  <style scoped>
  .container {
    max-width: 1200px;
  }
  
  .article-content :deep(pre) {
    background: #1e293b;
    color: #f8f8f2;
    border-radius: 8px;
    padding: 25px 15px 15px;
    font-size: 15px;
    position: relative;
    overflow-x: auto;
    margin: 1.5rem 0;
  }
  
  .article-content :deep(pre):before {
    content: '';
    position: absolute;
    top: 12px;
    left: 15px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 20px 0 #f59e0b, 40px 0 #10b981;
  }
  
  .article-content :deep(code) {
    font-family: 'Fira Code', 'Source Code Pro', Menlo, Monaco, Consolas, monospace;
  }
  
  .article-content :deep(pre code.hljs) {
    padding: 0;
    background: transparent;
    font-size: 0.95em;
  }
  
  .article-content :deep(p) {
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: #4b5563;
    font-size: 17px;
  }
  
  .dark .article-content :deep(p) {
    color: #d1d5db;
  }
  
  .article-content :deep(h1),
  .article-content :deep(h2),
  .article-content :deep(h3),
  .article-content :deep(h4),
  .article-content :deep(h5),
  .article-content :deep(h6) {
    margin: 2rem 0 1rem 0;
    color: #1f2937;
    font-weight: 700;
    line-height: 1.3;
  }
  
  .dark .article-content :deep(h1),
  .dark .article-content :deep(h2),
  .dark .article-content :deep(h3),
  .dark .article-content :deep(h4),
  .dark .article-content :deep(h5),
  .dark .article-content :deep(h6) {
    color: #f9fafb;
  }
  
  .article-content :deep(h2) {
    font-size: 1.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
  }
  
  .dark .article-content :deep(h2) {
    border-bottom-color: #374151;
  }
  
  .article-content :deep(h3) {
    font-size: 1.5rem;
  }
  
  .article-content :deep(ul) {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
  }
  
  .article-content :deep(ul li) {
    list-style-type: disc;
    padding: 0.25rem 0;
    font-size: 17px;
  }
  
  .article-content :deep(blockquote) {
    border-left: 4px solid #3b82f6;
    background-color: #eff6ff;
    padding: 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0 8px 8px 0;
  }
  
  .dark .article-content :deep(blockquote) {
    background-color: rgba(30, 64, 175, 0.15);
  }
  
  .article-content :deep(table) {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
  }
  
  .article-content :deep(th) {
    background-color: #f3f4f6;
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
  }
  
  .dark .article-content :deep(th) {
    background-color: #1f2937;
  }
  
  .article-content :deep(td) {
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
  }
  
  .dark .article-content :deep(td) {
    border-bottom-color: #374151;
  }
  
  .article-content :deep(tr:nth-child(even)) {
    background-color: #f9fafb;
  }
  
  .dark .article-content :deep(tr:nth-child(even)) {
    background-color: #111827;
  }
  
  .article-content :deep(a) {
    color: #3b82f6;
    text-decoration: underline;
    text-underline-offset: 3px;
  }
  
  .article-content :deep(a:hover) {
    color: #2563eb;
  }
  
  .dark .article-content :deep(a:hover) {
    color: #60a5fa;
  }
  
  .article-content :deep(img) {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem auto;
    display: block;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  }
  
  .sticky {
    position: sticky;
    top: 1.5rem;
  }
  
  .article-footer {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
  }
  
  .dark .article-footer {
    border-top-color: #374151;
  }
  
  .category-item, .tag-item {
    transition: all 0.2s ease;
  }
  
  .category-item:hover, .tag-item:hover {
    transform: translateY(-2px);
  }
  
  @media (max-width: 1024px) {
    .sticky {
      position: static;
    }
  }
  
  .line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  </style>